

function calendar() { 
	$(document).ready(function() {
		var _start; 
		var _end; 
		var task = $("#designation");
		var _timeStart = $("#start");
		var _timeEnd = $("#end");
		var _startY;
		var _startM;
		var _startD;
		var _endY;
		var _endM;
		var _endD;
		//var _startHours = _timeStartTab[0];
		//var _startMinutes = _timeStartTab[1];
		var _endHour;
		var _endMinure
		$("#submit").click(function(){ 
			//var validator = $("#form").validationEngine('validate');
				 // if(true){
					  $.ajax({
					      url: "/dydack/public/technical/order/index",
					      type: "POST",
					      data: "task=task",    // tu paramtery dodać
					      error: function() {alert('order error');},
					      success: function() {
					    	  //alert(_timeStart.val().split(":")[0]);
					    	  var _tabTimeStart = _timeStart.val().split(":");
					    	  var _tabTimeEnd = _timeEnd.val().split(":");
								calendar.fullCalendar('renderEvent',
										{
									
									title: task.val(),
									start: new Date(_startY, _startM, _startD, _tabTimeStart[0], _tabTimeStart[1]),
									end: new Date(_endY, _endM, _endD, _tabTimeEnd[0], _tabTimeEnd[1]),
									allDay: false
								},
								true 

							);
							
						    
							$( "#order-form").dialog( "close" );
							setTimeout('document.getElementById(\'zendForm\').reset()');
							

						}

					 });
				    
				    
				    //}
				    return false; 
			}); 

			//$("#form").validationEngine({promptPosition : "centerRight",scroll : true}); 
			$( "#dialog:ui-dialog" ).dialog( "destroy"); 
			$( "#order-form" ).dialog({ 
			      autoOpen: false, 
			      height: 600, 
			      width: 380, 
			      modal: true, 
			      buttons: { 

			      }, 
			      close: function() { 
			      } 


			}); 
			$("#cancelOrder").click(function() { 
			      $("#order-form").dialog( "close" ); 

			}); 
			
			var calendar = $('#calendar').fullCalendar({ 
				 
			      header: { 
				    left: 'prev,next today', 
				    center: 'title', 
				    right: 'month,agendaWeek,agendaDay' 
			      }, 
			      selectable: true, 
			      selectHelper: true, 
			      select: function(start, end, allDay) { 
				    //console.log("A" + start.toString()); 
				    
				   
					//_start = new Date(start.getFullYear(), start.getMonth(), start.getDate(), 19, 15);
				    _startY = start.getFullYear();
				    _startM = start.getMonth();
				    _startD = start.getDate();
					//_end = new Date(end.getFullYear(), end.getMonth(), end.getDate(), 22, 30);
				    _endY = end.getFullYear();
				    _endM = end.getMonth();
				    _endD = end.getDate();
					//_allDay = false;
				    $( "#order-form" ).dialog( "open" ); 
				    calendar.fullCalendar('unselect'); 
				}, 
				editable: true, 
				timeFormat: 'H(:mm)', 
				axisFormat: 'H(:mm)', 
				//defaultView : 'agendaWeek', 
				firstDay: 1 
			  }); 
		
	});	
		
			/*		
	
		var calendar = $('#calendar').fullCalendar({
			header: {
				left: 'prev,next today',
				center: 'title',
				right: 'month,agendaWeek,agendaDay'
			},
			selectable: true,
			selectHelper: true,
			select: function(start, end, allDay) {
				var title = prompt('Event Title:');
				if (title) {
					calendar.fullCalendar('renderEvent',
						{
							title: title,
							start: new Date(start.getFullYear(), start.getMonth(), start.getDay(), 19, 0),
							end: new Date(end.getFullYear(), end.getMonth(), end.getDay(), 22, 30),
							allDay: false
						},
						true // make the event "stick"
					);
				}
				calendar.fullCalendar('unselect');
			},
			editable: true,
		});
		
	});
	
		
		
		
		
		
		
		
		

		var _title;
		var _start; 
		var _end; 
		var _allDay; 
		var task = $("#task"); 
		var date = new Date();
		var d = date.getDate();
		var m = date.getMonth();
		var y = date.getFullYear();
		$("#acceptOrder").click(function(){ 
			//var validator = $("#form").validationEngine('validate');
				      if(true){
					  $.ajax({
					      url: "/dydack/public/technical/order/index",
					      type: "POST",
					      data: "task=task",    // tu paramtery dodać
					      error: function() {alert('eerrrr');},
					      success: function() {
								calendar.fullCalendar('renderEvent',
								{
									title: task.val(),
									//start: new Date(_start.getFullYear(), _start.getMonth(), _start.getDay() + 3, 19, 0),
									//end: new Date(_end.getFullYear(), _end.getMonth(), _end.getDay() + 3, 22, 0),
									start: new Date(y, m, d+1, 19, 0),
									end: new Date(y, m, d+1, 22, 30)
									
								},
								true 

							);
							
						    
							$( "#order-form").dialog( "close" );
							setTimeout('document.getElementById(\'form\').reset()');
							

						}

					 });
				    
				    
				    }
				    return false; 
			}); 

			//$("#form").validationEngine({promptPosition : "centerRight",scroll : true}); 
			$( "#dialog:ui-dialog" ).dialog( "destroy"); 
			$( "#order-form" ).dialog({ 
			      autoOpen: false, 
			      height: 600, 
			      width: 380, 
			      modal: true, 
			      buttons: { 

			      }, 
			      close: function() { 
			      } 


			}); 
			$("#cancelOrder").click(function() { 
			      $("#order-form").dialog( "close" ); 

			}); 

			
			var calendar = $('#calendar').fullCalendar({ 
			      header: { 
				    left: 'prev,next today', 
				    center: 'title', 
				    right: 'month,agendaWeek,agendaDay' 
			      }, 
			      selectable: true, 
			      selectHelper: true, 
			      select: function(start, end, allDay) { 
				    //console.log("A" + start.toString()); 
				    $( "#order-form" ).dialog( "open" ); 

				    _start = start; 
				    _end = end; 
				    _allDay = false; 
				    calendar.fullCalendar('unselect'); 
				}, 
				editable: true, 
				timeFormat: 'H(:mm)', 
				axisFormat: 'H(:mm)', 
				//defaultView : 'agendaWeek', 
				firstDay: 1 
			  }); 

		    }); 
	
		
		
		
		var date = new Date();
		var d = date.getDate();
		var m = date.getMonth();
		var y = date.getFullYear();
		
		var calendar = $('#calendar').fullCalendar({
			header: {
				left: 'prev,next today',
				center: 'title',
				right: 'month,agendaWeek,agendaDay'
			},
			selectable: true,
			selectHelper: true,
			select: function(start, end, allDay) {
				var title = prompt('Event Title:');
				if (title) {
					calendar.fullCalendar('renderEvent',
						{
							title: title,
							start: start,
							end: end,
							allDay: allDay
						},
						true // make the event "stick"
					);
				}
				calendar.fullCalendar('unselect');
			},
			editable: true,
			events: [
				{
					title: 'Birthday Party',
					start: new Date(y, m, d+1, 19, 0),
					end: new Date(y, m, d+1, 22, 30),
					allDay: false
				}
			],
			
			
		});
		
	});

*/
}